#coding=utf-8

from orm import Model, IntegerType, CharType, DatetimeType, Key, build_model
from settings import DEFAULT_USER_DB_NAME


@build_model
class OrgInfo(Model):
    _table = 'org_info'
    _name = '组织机构信息表'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id', comment='组织信息id', length=10, primary_key=True, unsigned=True, auto_increase=True)
    org_id = IntegerType(name='org_id', comment='用户id', length=11, unsigned=True, blank=False)
    org_name = CharType(name='org_name', comment='名称', length=20, blank=False)
    # 联系方式
    contact_name = CharType(name='contact_name', comment='联系人名字', length=8, blank=False)
    contact_wechat = CharType(name='contact_wechat', comment='微信号', length=64, blank=True)
    contact_qq = CharType(name='contact_qq', comment='QQ号', length=20, blank=True)
    contact_email = CharType(name='contact_email', comment='电子邮件', length=50, blank=True)
    contact_phone = CharType(name='contact_phone', comment='手机号码', length=11, blank=False)
    contact_telephone = CharType(name='contact_telephone', comment='固定电话', length=15, blank=True)
    location = CharType(name='location', comment='所在地', length=255, varchar=True, blank=True)
    # 预留信息
    org_intro = CharType(name='org_intro', comment='简介', length=255, varchar=True, blank=None)
    org_detail = CharType(name='org_detail', comment='详情', length=255, varchar=True, blank=None)
    # 登录使用信息
    create_at = DatetimeType(name='create_at', comment='创建时间', auto='on_create')
    update_at = DatetimeType(name='update_at', comment='更新时间', auto='on_update')
    # 索引
    index_org_id = Key(key_name='index_org_id', col_name='org_id')


@build_model
class Organ(Model):
    _table = 'organ'
    _name = '组织基本表'
    _conn_name = DEFAULT_USER_DB_NAME
    id = IntegerType(name='id', comment='用户id', length=10, primary_key=True, unsigned=True, auto_increase=True)
    login_name = CharType(name='login_name', comment='登录名', length=20, blank=False)
    password = CharType(name='password', comment='密码', length=50, blank=False)
    org_status = IntegerType(name='org_status', comment='组织状态', length=3, blank=0, unsigned=True)
    # 时戳
    create_at = DatetimeType(name='create_at', comment='创建时间', auto='on_create')
    update_at = DatetimeType(name='update_at', comment='更新时间', auto='on_update')
    # 索引
    index_org_login_name = Key(key_name='index_org_login_name', col_name='login_name')

